package cn.me.alphamq.nameserver.enumeration;

/**
 * 主从复制的复制类型的枚举类
 *
 * @author f
 */
public enum ReplicationTypeEnum {
    SYNC("sync", "同步复制"),
    HALF_SYNC("half_sync", "半同步复制"),
    ASYNC("async", "异步复制");

    // 根据枚举的 code 属性获取枚举
    public static ReplicationTypeEnum of(String code) {
        for (ReplicationTypeEnum type : ReplicationTypeEnum.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new RuntimeException("invalid replication type code: " + code);
    }

    private final String code;
    private final String desc;

    ReplicationTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
